<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="k" uri="/WEB-INF/k.tld"%>
<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>怀才进销存管理软件 - 销售前台</title>
		<jsp:include page="../inc.jsp"></jsp:include>
		<script type="text/javascript" src="../My97DatePicker/WdatePicker.js"></script>
		<link href="../web/css/style.css" rel="stylesheet" type="text/css" />
		<SCRIPT language="JavaScript" type="text/javascript" src="../web/js/hdm.js"></SCRIPT>
		<SCRIPT>
		var calendar;
		var datagrid;
		var lastIndex;
		$(function(){
			calendar = $('#calendar').calendar({
				fit : true,
				current : new Date(),
				border : false,
				onSelect : function(date) {
					$(this).calendar('moveTo', new Date());
				}
			});
			datagrid = $('#datagrid').datagrid({
				url : '${pageContext.request.contextPath}/xsgl/saleReturnlistAction!datagrid.html',
				title : '退货列表',
				iconCls : 'icon-save',
				pagination : true,
				pagePosition : 'bottom',
				pageSize : 10,
				pageList : [ 10, 20, 30, 40 ],
				fit : true,
				fitColumns : false,
				nowrap : false,
				border : false,
				idField : 'id',
				sortName : 'date',
				sortOrder : 'desc',
				checkOnSelect : false,
				selectOnCheck : false,
				singleSelect : true,
				columns : [ [  {
					title : '日期',
					field : 'date',
					width : 130,
					align:'center' 
				},{
					title : '编号',
					field : 'id',
					width : 120,
					align:'center',
					hidden: true
				}, {
					title : '退货单号',
					field : 'serial',
					width : 140,
					align:'center'
				},{
					title : '营业员',
					field : 'uusername',
					width : 100,
					align:'center'
				},{
					title : '会员姓名',
					field : 'mname',
					width : 100,
					align:'center'
				},{
					title : '出货仓库',
					field : 'rname',
					width : 80,
					align:'center'
				},{
					title : '退货总金额',
					field : 'total',
					width : 80,
					align:'center'
				}, {
					title : '销售单号',
					field : 'saleserial',
					width : 140,
					align:'center'
				}, {
					title : '&nbsp;&nbsp;&nbsp;&nbsp;备注',
					field : 'remark',
					width : 200
				}] ],
				toolbar : [ {
					text: '查看明细',
					iconCls:'icon-search',
					handler:function(){
						var rows = $('#datagrid').datagrid('getSelections');
						var id = rows[0].id;
						if(id!=null&&id!='undefinded'&&id!='null'){
							searchdetail(id)
						}
					}
				}],onDblClickRow:function(rowIndex, rowData){
					var rows = $('#datagrid').datagrid('getSelections');
					var id = rows[0].id;
					if(id!=null&&id!='undefinded'&&id!='null'){
						searchdetail(id)
					}
				}
			}); 
		});
		
		function searchdetail(id){
			$.ajax({
				url : '${pageContext.request.contextPath}/xsgl/saleReturnlistAction!findSaleReturnDetail.html?model.id='+id,
				dataType : 'JSON',
				type : 'POST',
				success:function(json){ 
				$('#mydialog').show(); 
				$('#mydialog').dialog({ 
				collapsible: false, 
				minimizable: false, 
				maximizable: false,
				closable:true,
				closed:false, 
				}); 
				closeMytableDialog();
				//alert(json.length);
				for(var i=0;i<json.length;i++){
					//alert(json.length);
					 $('#mytable').datagrid('appendRow',{
			            barcode:json[i].barcode,
			            type:json[i].type,
					    name:json[i].name,
					    bname:json[i].name, 
					    color:json[i].color,
					    size:json[i].size,
					    num:json[i].num,
					    total:json[i].total
				     });
				}
				
				$("#mytable").datagrid({
					onDblClickRow:function(rowIndex, rowData){ 
						top.closeMytableDialog();
					}
				});
				}
			});
		}
		function logout(){
			sy.messagerConfirm('请确认', '您确定要退出前台销售？', function(r) {
				if(r){
					$.ajax({
						url : '${pageContext.request.contextPath}/loginAction!logout.html',
						type : 'get',
						success:function(){
							self.location.reload();
							if(window.opener){
								opener.location = opener.location;
							}
							window.close();
						}
					});
				}
			});
		}
		
		function _search() {
			datagrid.datagrid('load', sy.serializeObject($('#searchForm')));
		}
		
		function cleanSearch() {
			datagrid.datagrid('load', {});
			$('#searchForm input').val(''); 
			$("#rid").val('');
			$("#uid").val('');
			_search();
		}
		
		function closeMytableDialog() { 
			$("#mytable").datagrid('loadData',{total:0,rows:[]});	
		} 
		
		</SCRIPT>
	</head>

	<body>
		<div class="top">
			<div class="logo">
				<img src="../web/imgs/htlogo.jpg" width="480" height="47" />
			</div>
			<div class="right">
				欢迎您！${sessionInfo.loginName} [${sessionInfo.roleNames}]
				<a href="javascript:void(0)" onclick="logout()">退出登录</a>
				
				<!-- 
					<a href="#">修改密码</a>
				-->
				
			</div>
		</div>
		<div class="content">
			<div class="right">
				<!--日历标题-->
				<div class="title">
					<img src="../web/imgs/pic1.gif" width="6" height="6" />
					日历
				</div>
				<!--/日历标题-->
				<!--日历-->
				<div style="height:180px;">
					<div id="calendar"></div>
				</div>
				<!--/日历-->
				<!--公告+提醒-->
				<div class="title">
					<ul>
						<li id="cp1" class="cpover" onMouseOver="setTab_('cp',1,5,'cpover')">
							公告<span class="tabRefresh"><a href="javascript:void(0);" onclick="javascript:document.frames('announcementIframe').location.reload()" class="icon-mini-refresh"></a></span>
						</li>
						<li id="cp2" onMouseOver="setTab_('cp',2,5,'cpover')">
							系统提醒<span class="tabRefresh"><a href="javascript:void(0);" onclick="javascript:document.frames('warnIframe').location.reload()" class="icon-mini-refresh"></a></span>
						</li>
					</ul>
				</div>
				<div class="conts">
					<div id="cp_con1">
						<iframe width="100%" height="400px;" scrolling="auto" frameborder="0" onload="javascript:void(0);" name="announcementIframe" id="announcementIframe" src="${pageContext.request.contextPath}/qtmk/announcementAction!noAuth_tabAnnounce.html"></iframe>
					</div>
					<div id="cp_con2" style="display: none;">
						<iframe width="100%" height="400px;" scrolling="no"  frameborder="0" onload="javascript:void(0);" name="warnIframe" id="warnIframe" src="${pageContext.request.contextPath}/qtmk/remindWarnAction!noAuth_tabRemindWarn.html"></iframe>
					</div>
				</div>
				<!--/公告+提醒-->
			</div>
			<div class="left">
				<div class="nav">
					<ul>
						<k:security key="XSGL_QTXS">
						<li>
							<a href="${pageContext.request.contextPath}/xsgl/sale.html">
								<img src="${pageContext.request.contextPath}/web/imgs/navxsgl.jpg" width="104" height="35" /> 
							</a>
						</li>
						</k:security>
						<k:security key="XSGL_XSTH">
						<li>
							<a href="${pageContext.request.contextPath}/xsgl/saleReturn.html">
								<img src="${pageContext.request.contextPath}/web/imgs/nav-xsth.jpg" width="104" height="35" /> 
							</a>
						</li>
						</k:security>
						<k:security key="XSGL_KCCX">
						<li>
							<a href="${pageContext.request.contextPath}/xsgl/amount.html">
								<img src="${pageContext.request.contextPath}/web/imgs/nav-kcgl.jpg" width="104" height="35" /> 
							</a>
						</li>
						</k:security>
						<k:security key="XSGL_HYGL">
						<li>
							<a href="${pageContext.request.contextPath}/xsgl/member.html">
								<img src="${pageContext.request.contextPath}/web/imgs/nav-hygl.jpg" width="104" height="35" /> 
							</a>
						</li>
						</k:security>
						<k:security key="XSGL_RJQS">
						<li>
							<a href="${pageContext.request.contextPath}/xsgl/settlement.html">
								<img src="${pageContext.request.contextPath}/web/imgs/nav-rjqs.jpg" width="104" height="35" /> 
							</a>
						</li>
						</k:security>
						<k:security key="XSGL_XSJLCX">
						<li>
							<a href="${pageContext.request.contextPath}/xsgl/salelist.html">
								<img src="../web/imgs/navxsglcx.jpg"  height="35" /> 
							</a>
						</li>
						</k:security>
						<k:security key="XSGL_THJLCX">
						<li>
							<a href="${pageContext.request.contextPath}/xsgl/saleReturnlist.html">
								<img src="../web/imgs/navthglcx.jpg" height="35" /> 
							</a>
						</li>
						</k:security>
					</ul>
				</div>
				<div class="cont">
					<div style="height: 120px; overflow: hidden;">
						<form id="searchForm">
							<table  style="width: 100%; height: 100%;">
								<tr>
									<th>所属仓库</th>
									<td>
										<select id="rid" name="rid" class="width1" id="rid" style="width: 200px;">
										<option value="">--请选择--</option>
											<c:forEach items="${VRepertories}" var="VRepertory">
												<option value='${VRepertory.id }'>${VRepertory.name }</option>
											</c:forEach>
										</select>
									</td>
									<th>营&nbsp;业&nbsp;员</th>
									<td>
										<select id="uid" name="uid" style="width: 200px;" id="uid">
											<option value=''>--请选择--</option>
											<c:forEach items="${VUsers}" var="VUser">
												<option value="${VUser.id }">${VUser.username }</option>
											</c:forEach>
										</select>
									</td>
								</tr>
								<tr>
									<th>开始时间</th>
									<td><input name="beginDate" style="width: 200px;" onClick="WdatePicker()"  class="input1"/></td>
									<th>结束时间</th>
									<td><input name="endDate" style="width: 200px;" onClick="WdatePicker()"  class="input1"/></td>
								</tr>
								<tr>
									<th>会员姓名</th>
									<td><input name="mSerial" style="width: 200px;"  class="input1"/></td>
									<th>商品款号</th>
									<td><input name="gtype" style="width: 200px;"  class="input1"/></td>
									
								</tr>
								<tr>
									<td colspan="4" align="center" style=" padding:2px 0 0px 400px;">
										<a href="javascript:void(0);" class="button2 dis_block fl m_l" onclick="_search();">搜索</a>
										<a href="javascript:void(0);" class="button3 dis_block fl m_l" onclick="cleanSearch();">取消</a>
									</td>
								</tr>
							</table>
						</form>
					</div>
					<div style="overflow: hidden;height:460px;">
						<table id="datagrid"></table>
					</div>
				</div>
			</div>
			
		</div>
		<br><br><br>
		<div id="mydialog" style="display:none;padding:5px;width:650px;height:auto;min-height:150px;max-height:300px;overflow-y:scrooll;" title="查看销售明细">		 		
		<table id="mytable" class="easyui-datagrid" style="height:auto"  data-options="iconCls: 'icon-edit',singleSelect: true"> 
		        <thead>
		            <tr>
		            	<th data-options="field:'barcode',width:130">商品条码</th>  
		            	<th data-options="field:'type',width:80">款号</th>  
	                 	 <th data-options="field:'name',width:90">商品名称</th> 
	                 	<th data-options="field:'bname',width:70">品牌</th> 
                   		<th data-options="field:'color',width:60,align:'center'">颜色</th>
                   		<th data-options="field:'size',width:60,align:'center'">尺码</th>
                   		<th data-options="field:'num',width:60,align:'center'">退货数量</th>
                   		<th data-options="field:'total',width:60,align:'center'">总金额</th>
		            </tr>
		        </thead>
		    </table>
		</div> 
		<div class="foot">
			Copyright @ 2013
			<a style="color:#FFFFFF; text-decoration:none;" target="_blank" href="http://www.miitbeian.gov.cn">浙ICP备13002014号-1</a>
			<br>
			杭州怀才商贸有限公司 服务电话：0571-28030726
		</div>
	</body>
</html>
